﻿using System;
using Xenta.Enums;

namespace Xenta.Attributes
{
    /// <summary>
    /// Represents the attribute, which allows to provide an 
    /// additional information about the dependency.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
    public class DependencyAttribute : Attribute
    {
        #region Fields

        private readonly string _id;

        #endregion

        #region Ctors

        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public DependencyAttribute() : 
            this(Guid.NewGuid().ToString())
        {
        }

        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="id">The dependency identifier.</param>
        public DependencyAttribute(string id)
        {
            _id = id;
            Lifestyle = DependencyLifestyle.Scoped;
            Version = "1.0.0";
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets the dependency identifier.
        /// </summary>
        public string ID
        {
            get
            {
                return _id;
            }
        }

        /// <summary>
        /// Gets or sets the component lifestyle. 
        /// The default lifestyle is "Scoped".
        /// </summary>
        public DependencyLifestyle Lifestyle
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the component name.
        /// </summary>
        /// <remarks>
        /// If name of component is empty, the component 
        /// will be registered using the name of the 
        /// component type.
        /// </remarks>
        public string Name
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the component version.
        /// </summary>
        public string Version
        {
            get;
            set;
        }

        #endregion
    }
}
